package com.lagou.edu.controller;


import com.lagou.edu.bean.ToEmail;
import com.lagou.edu.service.EmailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 */
@RestController
@Slf4j
public class EmailController {

    @Autowired
    private EmailService emailService;

    @GetMapping("/send/{email}/{code}")
    public boolean sendEmail(@PathVariable("email")String email, @PathVariable("code")String code){
        ToEmail toEmail = new ToEmail();
        toEmail.setTos(new String[]{email});
        toEmail.setSubject("注册验证码");
        toEmail.setContent("验证码：" + code);
        return emailService.sendEmail(toEmail);
    }
}
